<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Administrator
 */
namespace Admin\Model;
use Think\Model\RelationModel;

class OrderStatusHistoryModel  extends RelationModel {
    //put your code here
    protected  $tableName = 'order_status_history';

    protected $_link = array(
        'user'=>array(
            'mapping_type' => self::BELONGS_TO,
            'class_name' => 'Admin/User',
            'foreign_key' => 'user_id',
            'mapping_key' => 'id'
        )
    );

    public function detail($where) {
        $row = $this->relation(true)->where($where)->find();
        return $row;
    }

    public function getList($where) {
        $rows = $this->relation(true)->where($where)->select();
        return $rows;
    }

    public function add($data) {
        $data['add_time'] = time();
        return parent::add($data);
    }

    public function update($data,$where) {
        $data['edit_time'] = time();
        $rs = $this->where($where)->save($data);
        return $rs;
    }

    public function remove($where) {
        $rs = $this->where($where)->delete();
        return $rs;
    }
}